<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>ssoLogin</title>
</head>
<body>
<h1>ssoLogin</h1>
<form id="ssoLoginForm">
    <input type="hidden" id="redirectUrl" name="redirectUrl" th:value="${redirectUrl}">
    <label for="username">账号：</label><input type="text" id="username" name="username" autocomplete="off">
    <label for="password">密码：</label><input type="password" name="password" id="password">
    <button id="ssoLoginBtn">登 陆</button>
</form>

<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script>
    $(function () {
        $("#ssoLoginBtn").click(function () {
            $.ajax({
                url: "/login",
                type: "post",
                dataType: "json",
                data: $('#ssoLoginForm').serialize(),
                success: function (data) {
                    if (data.status == 1000) {
                        var redirectUrlVal = $("#redirectUrl").val();
                        if (redirectUrlVal != "") {
                            var redirectUrl = redirectUrlVal + "?token=" + data.data;
                            window.location = redirectUrl;
                            return;
                        }
                        window.location = "/admin";
                    } else {
                        alert(data.msg)
                    }
                },
                error: function () {
                    console.log("error");
                }
            });
            return false;
        })
    })
</script>
</body>
</html>